import db from "../knex";
import { Tables } from "../tables/tables-name-enum";
import { user_info__seed } from "./seeds";

// 种子数据
const seedsData = {};
seedsData[Tables.USER] = user_info__seed;

// 插入种子数据
export const insertSeedData = async () => {
    const arr: any[] = [];
    Object.keys(seedsData).forEach(tableName => {
        db(tableName).delete().then();
        const seedData = seedsData[tableName];
        for (const seed of seedData) {
            arr.push(db(tableName).insert(seed));
        }
    });
    return Promise.all(arr);
};
